package com.atguigu.gmallrealtime.util;

import com.atguigu.gmallrealtime.common.Constant;
import com.ververica.cdc.connectors.mysql.source.MySqlSource;
import com.ververica.cdc.connectors.mysql.table.StartupOptions;
import com.ververica.cdc.debezium.JsonDebeziumDeserializationSchema;

/**
 * @author yhm
 * @create 2023-09-22 14:28
 */
public class MysqlUtil {


    public static MySqlSource<String> getMySqlSource(String databaseName,String dbTableName){
        return MySqlSource.<String>builder()
                .hostname(Constant.MYSQL_HOST)
                .port(Constant.MYSQL_PORT)
                .username("root")
                .password("000000")
                .databaseList(databaseName)
                // 库名.表名
                .tableList(dbTableName)
                .startupOptions(StartupOptions.initial())
                .deserializer(new JsonDebeziumDeserializationSchema())
                .build();
    }
}
